// redux 3个3
// 3个api createStore combineReducers applyMiddleware
// 3个特点 store必须是单一数据 store中的状态是只读的 只能通过reducer修改状态
// 3个概念 store仓库 action对象{type:信号，payload负荷} reducer修改状态

import { legacy_createStore as createStore, combineReducers, applyMiddleware, compose } from "redux";
import logger from "redux-logger";
import thunk from 'redux-thunk'
import app from './modules/app'
import user from './modules/user'

const reducer = combineReducers({
    // 合并子仓库modules
    app,
    user
})

// 创建仓库需要分配一个管理员
// redux默认只能处理同步action
// thunk---处理异步代码  logger---打印仓库日志  先thunk再logger 顺序不能变
const store = createStore(reducer, compose(applyMiddleware(thunk), applyMiddleware(logger)))
console.log(store)

export default store